import { AxiosPromise } from "axios";
import {
  ClassDataFrom,
  ClassPageVO,
  ClassQuery,
  deleteClassDataFrom,
  modifyClassDataFrom,
  modifyViewClassDataFrom,
} from "./types";
import request from "@/utils/request";

/**
 * 班级分页列表
 *
 * @param queryParams
 */
export function getClassePage(
  queryParams: ClassQuery,
  courseId: number
): AxiosPromise<PageResult<ClassPageVO[]>> {
  return request({
    url: "/api/v1/system/class/list",
    method: "get",
    params: {
      ...queryParams,
      courseId,
    },
  });
}

/**
 * 创建班级
 *
 * @param queryParams
 */
export function AddClass(
  queryParams: ClassDataFrom,
  courseId: number
): AxiosPromise<void> {
  return request({
    url: "/api/v1/system/class/add",
    method: "post",
    params: {
      ...queryParams,
      courseId,
    },
  });
}

/**
 * 修改班级
 *
 * @param queryParams
 */
export function ModifyClass(
  queryParams: modifyClassDataFrom,
  courseId: number
): AxiosPromise<void> {
  return request({
    url: "/api/v1/system/class/update",
    method: "patch",
    params: {
      ...queryParams,
      courseId,
    },
  });
}

/**
 * 修改班级回显
 *
 * @param queryParams
 */
export function ModifyViewClass(
  classId: number
): AxiosPromise<modifyViewClassDataFrom> {
  return request({
    url: "/api/v1/system/class/echo/" + classId,
    method: "get",
  });
}

/**
 * 删除班级
 *
 * @param queryParams
 */
export function DeleteClass(
  queryParams: deleteClassDataFrom
): AxiosPromise<void> {
  return request({
    url: "/api/v1/system/class/remove",
    method: "delete",
    params: queryParams,
  });
}
